local skel=fk.CreateSkill{
    name = "steam__biaojue",
}

Fk:loadTranslationTable{
    ["steam__biaojue"] = "标爵",
    [":steam__biaojue"] = "横置技，当你需要使用【酒】时，你可以发动“制衡”，然后明置因此获得的牌；其他角色出牌阶段，其可以弃置任意张♦️牌，来获得等量张“标爵”牌。",
    ["@steam__biaojue"] = "标爵",
    ["biaojue_zhiheng"]="制衡",
    ["biaojue_active&"]="标爵",
    ["#steam__biaojue"]="标爵：你可以横置并发动制衡",
    [":biaojue_active&"]="出牌阶段,你可以弃置任意张♦️牌，来获得等量张“标爵”牌。",
    ["#biaojue_active"]="出牌阶段,你可以弃置任意张♦️牌，来获得等量张“标爵”牌。",
}
local DIY = require "packages/diy_utility/diy_utility"
skel:addEffect("active", {
    anim_type = "drawcard",
    prompt = "#steam__biaojue",
    target_num = 0,
    card_num = 0,
    can_use = function(self, player)
        return not player.chained and player:canUse(Fk:cloneCard("analeptic"))
    end,
    on_use = function(self, room, effect)
      local from = effect.from
      from:setChainState(true)
      local sucess,dat= room:askToUseActiveSkill(from,{
        skill_name = "biaojue_zhiheng",
    })
    end,
})

skel:addEffect(fk.AskForCardUse,{
    anim_type = "control",
    can_trigger = function(self, event, target, player, data)
        return  target == player and player:hasSkill(self) and  Exppattern:Parse(data.pattern):matchExp("analeptic")
        and not player.chained
    end,
    on_use = function(self, event, target, player, data)
        local room=player.room
        player:setChainState(true)
        local sucess,dat= room:askToUseActiveSkill(player,{
            skill_name = "biaojue_zhiheng",
        })
    end,
})



skel:addAcquireEffect(function (self, player, is_start)
    local room = player.room
    room:setBanner("biaojue_source",player.id)
    for _,p in ipairs(room:getOtherPlayers(player)) do
        room:handleAddLoseSkills(p,"biaojue_active&")
        
    end
end)

local skels={}
table.insert(skels,skel)


local zhiheng = fk.CreateSkill {
    name = "biaojue_zhiheng",
}
  
zhiheng:addEffect("active", {
    anim_type = "drawcard",
    prompt = "#zhiheng-active",
    max_phase_use_time = 1,
    target_num = 0,
    min_card_num = 1,
    card_filter = function(self, player, to_select)
      return not player:prohibitDiscard(to_select)
    end,
    on_use = function(self, room, effect)
      local from = effect.from
      room:throwCard(effect.cards, zhiheng.name, from, from)
      if from:isAlive() then
        local cards=from:drawCards(#effect.cards, zhiheng.name)
        DIY.showCards(from, cards)

      end
    end,
})


local biaojue_active = fk.CreateSkill {
    name = "biaojue_active&",
}

biaojue_active:addEffect("active", {
    anim_type = "drawcard",
    prompt = "#biaojue_active",
    target_num = 0,
    min_card_num = 1,
    card_filter = function(self, player, to_select)
        return not player:prohibitDiscard(to_select) and Fk:getCardById(to_select).suit == Card.Diamond
    end,
    can_use = function(self, player)
       local room=Fk:currentRoom()
       local source=room:getBanner("biaojue_source")
       local source_player=room:getPlayerById(source)
       return #DIY.getShownCards(source_player)>0
      end,
    on_use = function(self, room, effect)
        local from = effect.from
        local sourceid=room:getBanner("biaojue_source")
        
        local source=room:getPlayerById(sourceid)
        local n=#effect.cards
        room:throwCard(effect.cards, zhiheng.name, from, from)
        local cards=DIY.getShownCards(source)
        local n=math.min(n,#cards)
        local card_data={}
        table.insert(card_data, { Fk:translate(source.general).." ", cards })
        local result = room:askToChooseCards(from, {
            min = n,
            max = n,
            target = source,
            flag = {
                card_data = {{biaojue_active.name, cards}}
              },
            skill_name=biaojue_active.name,
            cancelable = false,
        })
        room:obtainCard(from,result,false,fk.ReasonGive,from)
        if from.kingdom=="han" then
            room:setPlayerMark(from,"biaojue_han",1)
        end
    end,
})
  


table.insert(skels,zhiheng)
table.insert(skels,biaojue_active)


return skels